define(function (require) {
    var Base = require('group/common/main');
    var utils = require('common/utils/home');
    var Mask = require('common/mask');
    var mask = new Mask();
    var TimeHtml = require('text!./templates/time.html');

    return Base.extend({
        initialize: function (params) {
            var _this = this;
            Base.prototype.initialize.apply(this, [params]);
            if (_this['page_' + _global.a]) {
                _this['page_' + _global.a]();
            }
        },
        page_index: function () {
            var _this = this;
            var interval = setInterval(function () {
                var stime = _.strtotime(_global.topic_info.stime);
                var etime = _.strtotime(_global.topic_info.etime);
                var html;
                if (stime > _.time()) {
                    html = _this.render(TimeHtml, {status: -1});
                }
                else if (stime < _.time() && _.time() < etime) {
                    var day = _.intval((etime - _.time()) / (3600 * 24));
                    var hour = _.intval((etime - _.time() - day * 3600 * 24) / 3600);
                    var minute = _.intval((etime - _.time() - day * 3600 * 24 - hour * 3600) / 60);
                    var second = etime - _.time() - day * 3600 * 24 - hour * 3600 - minute * 60;
                    html = _this.render(TimeHtml, {status: 0, day: day, hour: hour, minute: minute, second: second});
                }
                else if (etime < _.time()) {
                    html = _this.render(TimeHtml, {status: 1});
                    clearInterval(interval);
                }
                _this.$('#J_topic_time').html(html);
            }, 1000);
            _this.waterfall();
        },
        page_lists: function () {
            var _this = this;
            _this.$('.index-rec-banner a img').css({
                width: _this.page_width() + 'px',
                height: _this.page_width() / 2 + 'px'
            });
        }
    });
});